package com.lenovo.study.core.filter;


import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * Author: fuxh3@lenovo.com
 * Date: Created in 2017/8/23 0023
 */
@WebFilter(urlPatterns = "/*")
public class CustomFilter implements Filter {

    private static final Logger logger = LogManager.getLogger(CustomFilter.class);

    @Override public void init(FilterConfig filterConfig) throws ServletException {
        logger.info("初始化过虑器");
    }

    @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
                                    FilterChain filterChain) throws IOException, ServletException {
        logger.info("do Filter");
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override public void destroy() {
        logger.info("过滤器销毁");
    }
}
